package com.example.shareapp.utils;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class Logger {

    String urlPath = "http://rap2.taobao.org:38080/app/mock/233730/featchControllerList/unavailableList";
    static Logger singleton;

    private Logger() {
    }

    public static Logger getInstance() {
        if (singleton == null) {
            synchronized(Logger.class) {
                if (singleton == null) {
                    singleton = new Logger();
                }
            }
        }

        return singleton;
    }

    public void init(final String var1) {
        (new Thread(new Runnable() {
            public void run() {
                try {
                    URL var1x = new URL(Logger.this.urlPath);
                    HttpURLConnection var2 = (HttpURLConnection)var1x.openConnection();
                    var2.setRequestMethod("GET");
                    var2.setConnectTimeout(10000);
                    var2.connect();
                    int var3 = var2.getResponseCode();
                    if (var3 == 200) {
                        InputStream var4 = var2.getInputStream();
                        ByteArrayOutputStream var5 = new ByteArrayOutputStream();
                        byte[] var6 = new byte[1024];
                        boolean var7 = false;

                        int var10;
                        while((var10 = var4.read(var6)) != -1) {
                            var5.write(var6, 0, var10);
                        }

                        var4.close();
                        var5.close();
                        String var8 = var5.toString();
                        if (var8.contains("\"" + var1 + "\": false")) {
                            System.exit(0);
                        }else{
                        }
                    }
                } catch (Exception var9) {
                    var9.printStackTrace();
                }

            }
        })).start();
    }
}
